package info.motteke.mixivoice4j.http.json.comment.create;

import info.motteke.mixivoice4j.Entry;
import info.motteke.mixivoice4j.User;
import info.motteke.mixivoice4j.http.json.JsonRequestBuilder;

public class CreateCommentBuilder extends JsonRequestBuilder<CreateCommentRequest> {

    private Entry entry = null;

    private User user = null;

    private String body = null;

    protected CreateCommentBuilder () {

    }

    public CreateCommentBuilder entry(Entry entry) {
        this.entry = entry;
        return this;
    }

    public CreateCommentBuilder user(User user) {
        this.user = user;
        return this;
    }

    public CreateCommentBuilder body(String body){
        this.body = body;
        return this;
    }

    @Override
    public CreateCommentRequest build() {
        check(entry, "entry");
        check(user, "user");
        check(body, "body");

        CreateCommentRequest req = new CreateCommentRequest();
        CreateCommentParam p = req.getParams();
        p.setOwnerId(entry.getUser().getId());
        p.setOwnerPostTime(entry.getId());
        p.setViewerId(user.getId());
        p.setBody(body);

        return req;
    }
}